package com.zingrow.web.InformationDistribute.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.idaycrm.idaybase.utils.JsonUtils;
import com.zingrow.common.ReturnStandardDataFormat;
import com.zingrow.common.utils.CommonUtils;
import com.zingrow.common.utils.EncodingUtils;
import com.zingrow.common.utils.StringUtil;
import com.zingrow.web.InformationDistribute.dao.InformationDistributeDao;
import com.zingrow.web.InformationDistribute.dao.impl.InformationDistributeDaoImpl;
import com.zingrow.web.base.CodeMsg;
import com.zingrow.web.base.controller.BaseController;
import com.zingrow.web.configure.enshrine.model.Enshrine;
import com.zingrow.web.configure.enshrine.service.IEnshrineService;
import com.zingrow.web.configure.iformation.model.Iformation;
import com.zingrow.web.configure.iformation.service.IIformationService;
import com.zingrow.web.entity.InformationDistribute;
import com.zingrow.web.jms.JMSProducer;
import com.zingrow.web.push.bind.model.Bind;
import com.zingrow.web.push.bind.service.IBindService;
import com.zingrow.web.support.operate.service.IOptRecordService;
import com.zingrow.web.user.model.User;
import com.zingrow.web.user.model.UserPermission;
import com.zingrow.web.user.service.IUserService;
import com.zzyq.dataManager.bean.MessageText;
import com.zingrow.web.base.enums.OperationModule;
import com.zingrow.web.base.enums.OperationMinModule;
import com.zingrow.web.base.enums.OperationDeed;

/**
 * 手机端信息方案接口
 *
 *
 * @author shengchen
 *
 * @time:2017年3月3日 下午4:16:43
 */
@Controller
@RequestMapping(value = "/informationDistribute/", produces = "application/json;charset=UTF-8")
public class InformationDistributeController extends BaseController {

	@Autowired
	private IBindService bindService;

	@Autowired
	private IEnshrineService enshrineService;

	@Autowired
	private IIformationService iformationService;

	@Autowired
	private IOptRecordService optRecordService;

	@Autowired
	private IUserService userService;

	private InformationDistributeDao informationDistributeDao = new InformationDistributeDaoImpl();

	/**
	 * 点击推送
	 * 
	 * @param httpRequest
	 * @param response
	 * @param ifmid
	 * @return
	 */
	@ResponseBody
	@RequestMapping("Push")
	public String Push(HttpServletRequest httpRequest, HttpServletResponse response, String ifmid, String ArticleId,
			String Title) {
		ReturnStandardDataFormat standardData = new ReturnStandardDataFormat(CodeMsg.CODE_ERROR, CodeMsg.MSG_ERROR,
				null);
		try {
			if (ifmid != null || "".equals(ifmid)) {
				ifmid = EncodingUtils.fixUrlParamEncoding(httpRequest, ifmid);
			} else {
				log.error("方案ID不正确");
				standardData.setReturnCode(CodeMsg.CODE_EXCEPTION);
				standardData.setReturnMessage(CodeMsg.MSG_EXCEPTION);
				return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
			}
			if (ArticleId != null || "".equals(ArticleId)) {
				ArticleId = EncodingUtils.fixUrlParamEncoding(httpRequest, ArticleId);
			} else {
				log.error("ArticleId不正确");
				standardData.setReturnCode(CodeMsg.CODE_EXCEPTION);
				standardData.setReturnMessage(CodeMsg.MSG_EXCEPTION);
				return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
			}
			if (Title != null || "".equals(Title)) {
				Title = EncodingUtils.fixUrlParamEncoding(httpRequest, Title);
			} else {
				log.error("Title不正确");
				standardData.setReturnCode(CodeMsg.CODE_EXCEPTION);
				standardData.setReturnMessage(CodeMsg.MSG_EXCEPTION);
				return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
			}
			MessageText message = new MessageText();
			message.setIfmId(ifmid);
			message.setArticleId(ArticleId);
			message.setTitle(Title);
			JMSProducer.sendMessage(message);
		} catch (Exception e) {
			log.error("推送发生异常");
			log.error(e.getMessage());
			standardData.setReturnCode(CodeMsg.CODE_EXCEPTION);
			standardData.setReturnMessage(CodeMsg.MSG_EXCEPTION);
		}
		standardData.setReturnCode(CodeMsg.CODE_OK);
		standardData.setReturnMessage(CodeMsg.MSG_OK);
		return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
	}

	/**
	 * 当个方案初始化10条数据
	 * 
	 * @param httpRequest
	 * @param response
	 * @param ifmid
	 * @return
	 */
	@ResponseBody
	@RequestMapping("queryInitById")
	public String queryInitById(HttpServletRequest httpRequest, HttpServletResponse response, String ifmid) {
		List<InformationDistribute> returnList = new ArrayList<>();
		ReturnStandardDataFormat standardData = new ReturnStandardDataFormat(CodeMsg.CODE_ERROR, CodeMsg.MSG_ERROR,
				returnList);
		try {
			if (ifmid != null || "".equals(ifmid)) {
				ifmid = EncodingUtils.fixUrlParamEncoding(httpRequest, ifmid);
			}
			returnList = informationDistributeDao.queryInitById(InformationDistribute.class, ifmid);
		} catch (Exception e) {
			log.error("根据参数查询发生异常");
			log.error(e.getMessage());
			standardData.setReturnCode(CodeMsg.CODE_EXCEPTION);
			standardData.setReturnMessage(CodeMsg.MSG_EXCEPTION);
			standardData.setReturnData(returnList);
		}
		for (int i = 0; i < returnList.size(); i++) {
			returnList.get(i).setContent(null);
		}
		standardData.setReturnData(returnList);
		standardData.setReturnCode(CodeMsg.CODE_OK);
		standardData.setReturnMessage(CodeMsg.MSG_OK);
		return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
	}

	/**
	 * 单个方案ID 时间戳 参数 正序排序查询10条数 上划时查询后续数据
	 */

	@ResponseBody
	@RequestMapping("queryByIDlastTimestamp")
	public String queryByIDlastTimestamp(HttpServletRequest httpRequest, HttpServletResponse response, String ifmid,
			@RequestParam(required = false) String timestamp) {
		List<InformationDistribute> returnList = new ArrayList<>();
		ReturnStandardDataFormat standardData = new ReturnStandardDataFormat(CodeMsg.CODE_ERROR, CodeMsg.MSG_ERROR,
				returnList);
		try {

			if (ifmid != null || "".equals(ifmid)) {
				ifmid = EncodingUtils.fixUrlParamEncoding(httpRequest, ifmid);
			}
			returnList = informationDistributeDao.queryByIDlastTimestamp(InformationDistribute.class, ifmid,
					StringUtils.isNotBlank(timestamp) ? Long.valueOf(Long.parseLong(timestamp)) : null);
		} catch (Exception e) {
			log.error("根据参数查询发生异常");
			log.error(e.getMessage());
			standardData.setReturnCode(CodeMsg.CODE_EXCEPTION);
			standardData.setReturnMessage(CodeMsg.MSG_EXCEPTION);
			standardData.setReturnData(returnList);
		}
		standardData.setReturnData(returnList);
		standardData.setReturnCode(CodeMsg.CODE_OK);
		standardData.setReturnMessage(CodeMsg.MSG_OK);
		return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
	}

	/**
	 * 根据用户名称获取对应的所有栏目
	 */

	@ResponseBody
	@RequestMapping("queryIformationByUserName")
	public String queryIformationByUserName(HttpServletRequest httpRequest, HttpServletResponse response,
			String user_account) {
		List<Iformation> returnList = new ArrayList<>();
		ReturnStandardDataFormat standardData = new ReturnStandardDataFormat(CodeMsg.CODE_ERROR, CodeMsg.MSG_ERROR,
				returnList);
		try {

			if (user_account != null || "".equals(user_account)) {
				user_account = EncodingUtils.fixUrlParamEncoding(httpRequest, user_account);
			}
			// List<Iformation> list =
			// iformationService.queryIformationByUserName(user_account);
			// 根据用户名称得到用户id
			User user = userService.selectName(user_account);
			// 根据用户id得到用户拥有哪些方案
			UserPermission permission = userService.selectByUserId(user.getUserId());
			if (permission == null) {
				log.error("该用户没有任何方案权限");
				standardData.setReturnData(returnList);
				standardData.setReturnCode(Integer.valueOf(10007));
				standardData.setReturnMessage("请联系管理员添加栏目");
				addOptRecode(httpRequest, optRecordService, "", "", "", "该用户没有任何方案权限,请联系管理员添加栏目,错误码：10007");
				return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
			}
			// 字符串分割
			List<String> list = new ArrayList<String>();
			if (CommonUtils.isStrNotNull(permission.getRopeProgramme())) {
				list = StringUtil.toStringTokenizer(permission.getRopeProgramme(), ",");
				// 根据方案id得到方案名称和方案id
				returnList = iformationService.selectId(list);
				// 如果集合内的类别名称为空，赋值为监测
				for (int i = 0; i < returnList.size(); i++) {
					if (returnList.get(i).getIfm_categoryName() == null
							|| returnList.get(i).getIfm_categoryName().equals("")) {
						returnList.get(i).setIfm_categoryName("监测");
					}
				}
			}
			if (returnList.size() <= 0) {
				log.error("该用户没有任何方案权限");
				standardData.setReturnData(returnList);
				standardData.setReturnCode(Integer.valueOf(10007));
				standardData.setReturnMessage(CodeMsg.MSG_MODEL_DATA_ERROR);
				addOptRecode(httpRequest, optRecordService, "", "", "", "该用户没有任何方案权限,请联系管理员添加栏目,错误码：10007");
				return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
			}

		} catch (Exception e) {
			log.error("根据参数查询发生异常");
			log.error(e.getMessage());
			standardData.setReturnCode(CodeMsg.CODE_EXCEPTION);
			standardData.setReturnMessage(CodeMsg.MSG_EXCEPTION);
			standardData.setReturnData(returnList);
			return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
		}
		standardData.setReturnData(returnList);
		standardData.setReturnCode(CodeMsg.CODE_OK);
		standardData.setReturnMessage(CodeMsg.MSG_OK);
		return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
	}

	/**
	 * 根据文章ID获取相似信息
	 */
	@ResponseBody
	@RequestMapping("queryLikeByarticleId")
	public String queryLikeByarticleId(HttpServletRequest httpRequest, HttpServletResponse response, String ifmId,
			String groupId, String timestamp) {
		List<InformationDistribute> returnList = new ArrayList<>();
		ReturnStandardDataFormat standardData = new ReturnStandardDataFormat(CodeMsg.CODE_ERROR, CodeMsg.MSG_ERROR,
				returnList);
		try {

			if (groupId != null || "".equals(groupId)) {
				groupId = EncodingUtils.fixUrlParamEncoding(httpRequest, groupId);
			}
			if (ifmId != null || "".equals(ifmId)) {
				ifmId = EncodingUtils.fixUrlParamEncoding(httpRequest, ifmId);
			}
			returnList = informationDistributeDao.queryLikeByGroupId(InformationDistribute.class, ifmId, groupId,
					StringUtils.isNotBlank(timestamp) ? Long.valueOf(Long.parseLong(timestamp)) : null);
		} catch (Exception e) {
			log.error("根据参数查询发生异常");
			log.error(e.getMessage());
			standardData.setReturnCode(CodeMsg.CODE_EXCEPTION);
			standardData.setReturnMessage(CodeMsg.MSG_EXCEPTION);
			standardData.setReturnData(returnList);
		}
		standardData.setReturnData(returnList);
		standardData.setReturnCode(CodeMsg.CODE_OK);
		standardData.setReturnMessage(CodeMsg.MSG_OK);
		return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
	}

	/**
	 * 通过文章ID获取文章详情
	 */
	@ResponseBody
	@RequestMapping("queryContentByArticleId")
	public String queryContentByArticleId(HttpServletRequest httpRequest, HttpServletResponse response, String ifmId,
			String articleId, String user_account, String moduleId) {
		InformationDistribute distribute = new InformationDistribute();
		ReturnStandardDataFormat standardData = new ReturnStandardDataFormat(CodeMsg.CODE_ERROR, CodeMsg.MSG_ERROR,
				distribute);
		try {
			// 判断ifmid为空则articleId传的值为_id，据此查询出数据在进行查询........
			if (ifmId == null || "".equals(ifmId) || ifmId.equals("0")) {
				if (articleId != null || "".equals(articleId)) {
					articleId = EncodingUtils.fixUrlParamEncoding(httpRequest, articleId);
				}
				distribute = informationDistributeDao.queryContentById(InformationDistribute.class, articleId);
				articleId = distribute.getArticleId();
				ifmId = distribute.getIfmId();
			}
			if (articleId != null || !"".equals(articleId)) {
				articleId = EncodingUtils.fixUrlParamEncoding(httpRequest, articleId);
			}

			if (ifmId != null || !"".equals(ifmId)) {
				ifmId = EncodingUtils.fixUrlParamEncoding(httpRequest, ifmId);
			}
			if (moduleId != null || !"".equals(moduleId)) {
				moduleId = EncodingUtils.fixUrlParamEncoding(httpRequest, moduleId);
			}
			distribute = informationDistributeDao.queryContentByArticleId(InformationDistribute.class, articleId,
					ifmId);
			// 用户已收藏的高亮
			List<Enshrine> enshrine = enshrineService.queryByArticleIdAndUserAccount(articleId, user_account);
			if (enshrine.size() > 0) {
				distribute.setIsCollection(1);
			}

		} catch (Exception e) {
			log.error("根据参数查询发生异常");
			log.error(e.getMessage());
			addOptRecode(httpRequest, optRecordService, "", "", "查看异常", "通过文章ID获取文章详情异常，异常模块id" + moduleId);
			standardData.setReturnCode(CodeMsg.CODE_EXCEPTION);
			standardData.setReturnMessage(CodeMsg.MSG_EXCEPTION);
			standardData.setReturnData(distribute);
		}
		/*
		 * if (distribute.getArticleId() == null) {
		 * standardData.setReturnData(distribute);
		 * standardData.setReturnCode(CodeMsg.CODE_EXCEPTION);
		 * standardData.setReturnMessage("查询的信息不存在！"); addOptRecode(httpRequest,
		 * optRecordService, "", "", "","文章id为空"); return
		 * JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss"); }
		 */
		// 通过方案id查询类别名称与方案名称
		String categoryName = iformationService.appselectbyifmId(ifmId);
		String ifmName = iformationService.ifmNamebyifmId(ifmId);
		String title = distribute.getTitle();
		String weiboTitle = distribute.getUrl();
		if (title == null || title.equals("")) {
			title = weiboTitle;
		}
		if (categoryName == null || categoryName.equals("")) {
			categoryName = "监测";
		}
		if (distribute.getArticleId() != null) {
			//判断参数
			if(StringUtils.isNotBlank(moduleId)){		
			// 添加操作日志
			if (moduleId.equals("1")) {
				addOptRecode(httpRequest, optRecordService, OperationModule.monitor.toString(),
						categoryName + "-" + ifmName, OperationDeed.check.toString() + "《" + title + "》", "");
			} else if (moduleId.equals("2")) {
				addOptRecode(httpRequest, optRecordService, OperationModule.me.toString(),
						OperationMinModule.collection.toString(),
						OperationDeed.checkCollection.toString() + "《" + title + "》", "");
			} else if (moduleId.equals("3")) {
				addOptRecode(httpRequest, optRecordService, OperationModule.me.toString(),
						OperationMinModule.history.toString(), OperationDeed.check.toString() + "《" + title + "》", "");
			} else if (moduleId.equals("4")) {
				addOptRecode(httpRequest, optRecordService, OperationModule.monitor.toString(),
						categoryName + "-" + ifmName, OperationDeed.pushCheck.toString() + "《" + title + "》", "");
			}
			}
		} else {
			standardData.setReturnData(distribute);
			standardData.setReturnCode(CodeMsg.CODE_EXCEPTION);
			standardData.setReturnMessage("查询的信息不存在！");
			//判断参数
			if(StringUtils.isNotBlank(moduleId)){
			// 添加操作日志
			if (moduleId.equals("1")) {
				addOptRecode(httpRequest, optRecordService, OperationModule.monitor.toString(),
						categoryName + "-" + ifmName, OperationDeed.check.toString() + "《" + title + "》", "后台已删除该文章");
			} else if (moduleId.equals("2")) {
				addOptRecode(httpRequest, optRecordService, OperationModule.me.toString(),
						OperationMinModule.collection.toString(),
						OperationDeed.checkCollection.toString() + "《" + title + "》", "后台已删除该文章");
			} else if (moduleId.equals("3")) {
				addOptRecode(httpRequest, optRecordService, OperationModule.me.toString(),
						OperationMinModule.history.toString(), OperationDeed.check.toString() + "《" + title + "》", "后台已删除该文章");
			} else if (moduleId.equals("4")) {
				addOptRecode(httpRequest, optRecordService, OperationModule.monitor.toString(),
						categoryName + "-" + ifmName, OperationDeed.pushCheck.toString() + "《" + title + "》", "后台已删除该文章");
			}
			}
		}			
		standardData.setReturnData(distribute);
		standardData.setReturnCode(CodeMsg.CODE_OK);
		standardData.setReturnMessage(CodeMsg.MSG_OK);
		return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
	}

	/**
	 * 查看用户已收藏的文章
	 * 
	 * @param httpRequest
	 * @param response
	 * @param user_account
	 * @return
	 */
	@ResponseBody
	@RequestMapping({ "queryUserEnshrine" })
	public String queryUserEnshrine(HttpServletRequest httpRequest, HttpServletResponse response, String user_account,
			@RequestParam(required = false) String timestamp) {
		List<InformationDistribute> returnList = new ArrayList<>();
		ReturnStandardDataFormat standardData = new ReturnStandardDataFormat(Integer.valueOf(10001), "操作失败",
				returnList);

		List<Enshrine> list = new ArrayList<>();
		try {
			if ((user_account != null) || ("".equals(user_account))) {
				user_account = EncodingUtils.fixUrlParamEncoding(httpRequest, user_account);
			}
			list = this.enshrineService.queryByUserAccount(user_account);
			List<String> articleId = new ArrayList<>();
			List<String> ifmids = new ArrayList<>();
			for (int i = 0; i < list.size(); i++) {
				articleId.add(((Enshrine) list.get(i)).getArticleId());
				ifmids.add(list.get(i).getIfm_id());
			}
			returnList = this.informationDistributeDao.queryUserEnshrine(InformationDistribute.class, ifmids, articleId,
					StringUtils.isNotBlank(timestamp) ? Long.valueOf(Long.parseLong(timestamp)) : null);
		} catch (Exception e) {
			this.log.error("根据参数查询发生异常");
			this.log.error(e.getMessage());
			standardData.setReturnCode(Integer.valueOf(10003));
			standardData.setReturnMessage("操作异常");
			return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
		}
		standardData.setReturnData(returnList);
		standardData.setReturnCode(Integer.valueOf(10000));
		standardData.setReturnMessage("操作成功");
		return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
	}

	public static String escapeExprSpecialWord(String keyword) {
		if (!StringUtils.isEmpty(keyword)) {
			String[] fbsArr = { "\\", "$", "(", ")", "*", "+", ".", "[", "]", "?", "^", "{", "}", "|" };
			for (String key : fbsArr) {
				if (keyword.contains(key)) {
					keyword = keyword.replace(key, "\\" + key);
				}
			}
		}
		return keyword;
	}

	/**
	 * 用户搜索
	 */
	@ResponseBody
	@RequestMapping({ "queryKewWorkLike" })
	public String queryKewWorkLike(HttpServletRequest httpRequest, HttpServletResponse response, String KewWord,
			String user_account, @RequestParam(required = false) String timestamp) {
		List<InformationDistribute> returnList = new ArrayList<>();
		ReturnStandardDataFormat standardData = new ReturnStandardDataFormat(Integer.valueOf(10001), "操作失败",
				returnList);
		// List<Iformation> list = new ArrayList<>();
		try {
			if ((user_account != null) || ("".equals(user_account))) {
				user_account = EncodingUtils.fixUrlParamEncoding(httpRequest, user_account);
			}
			if ((KewWord != null) || ("".equals(KewWord))) {
				KewWord = EncodingUtils.fixUrlParamEncoding(httpRequest, KewWord);
			}
			// 用户输入的特殊字符强制清除
			// String
			// regEx="[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]";
			// Pattern p = Pattern.compile(regEx);
			// Matcher m = p.matcher(KewWord);
			// KewWord = m.replaceAll("").trim();
			String keyword = escapeExprSpecialWord(KewWord);
			// list = iformationService.queryIformationByUserName(user_account);
			// List<String> ifmIds = new ArrayList<>();
			// for (int i = 0; i < list.size(); i++) {
			// ifmIds.add(list.get(i).getIfm_id().toString());
			// }
			// 根据用户名称得到用户id
			User user = userService.selectName(user_account);
			// 根据用户id得到用户拥有哪些方案
			UserPermission permission = userService.selectByUserId(user.getUserId());
			if (permission == null) {
				log.error("该用户没有任何方案权限");
				standardData.setReturnData(returnList);
				standardData.setReturnCode(Integer.valueOf(10007));
				standardData.setReturnMessage("请联系管理员添加栏目");
				addOptRecode(httpRequest, optRecordService, "", "", "", "该用户没有任何方案权限,请联系管理员添加栏目,错误码：10007");
				return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
			}
			String ifmId = permission.getRopeProgramme();
			returnList = informationDistributeDao.queryKewWorkLike(InformationDistribute.class, keyword,
					StringUtils.isNotBlank(timestamp) ? Long.valueOf(Long.parseLong(timestamp)) : null,
					StringUtil.toStringTokenizer(ifmId, ","));
			for (int i = 0; i < returnList.size(); i++) {
				returnList.get(i).setContent(null);
			}
		} catch (Exception e) {
			this.log.error("根据参数查询发生异常");
			this.log.error(e.getMessage());
			standardData.setReturnCode(Integer.valueOf(10003));
			standardData.setReturnMessage("操作异常");
			addOptRecode(httpRequest, optRecordService, "", "", "", "根据参数查询发生异常,错误码：10003");
			return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
		}
		// 添加记录
		addOptRecode(httpRequest, optRecordService, OperationModule.monitor.toString(), "搜索", "搜索：" + KewWord, "");
		standardData.setReturnData(returnList);
		standardData.setReturnCode(Integer.valueOf(10000));
		standardData.setReturnMessage("操作成功");
		return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
	}

	/**
	 * Badge初始化
	 */
	@ResponseBody
	@RequestMapping({ "modifyBadge" })
	public String modifyBadge(HttpServletRequest httpRequest, HttpServletResponse response, String account,
			String appChannelId) {
		Bind bind = new Bind();
		ReturnStandardDataFormat standardData = new ReturnStandardDataFormat(Integer.valueOf(10001), "操作失败", bind);
		try {
			if ((account != null) || ("".equals(account))) {
				account = EncodingUtils.fixUrlParamEncoding(httpRequest, account);
			}
			if ((appChannelId != null) || ("".equals(appChannelId))) {
				appChannelId = EncodingUtils.fixUrlParamEncoding(httpRequest, appChannelId);
			}
			bind.setUser_account(account);
			bind.setBaidu_channel_id(appChannelId);
			bind.setBadge(0);
			bindService.modifyBadge(bind);
		} catch (Exception e) {
			this.log.error("根据参数修改发生异常");
			this.log.error(e.getMessage());
			standardData.setReturnCode(Integer.valueOf(10003));
			standardData.setReturnMessage("操作异常");
			return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
		}
		standardData.setReturnData(bind);
		standardData.setReturnCode(Integer.valueOf(10000));
		standardData.setReturnMessage("操作成功");
		return JsonUtils.toString(standardData, "yyyy-MM-dd HH:mm:ss");
	}

}
